package com.enjoy.adv.kryocodec;

import com.enjoy.adv.vo.MyMessage;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * Created by HP on 2019/7/18.
 * 序列化handler 编码
 */
public class kryoEncoder extends MessageToByteEncoder<MyMessage> {

    @Override
    protected void encode(ChannelHandlerContext ctx, MyMessage msg, ByteBuf out) throws Exception {
        KryoSerializer.serialize(msg,out);
        ctx.flush();
    }
}
